int gQuickSort[20];
void quick_sort(int array[], int length)
{
    int median = 0;
    if(NULL == array || 0 == length)
        return ;
    _quick_sort(array, 0, length-1);
}

void _quick_sort(int array[], int start, int end)
{
    int middle;
    if(start >= end)
        return;

    middle = get_middle(array, start, end);
    _quick_sort(array, start, middle-1);
    _quick_sort(array, middle-1, end);
}

 int get_middle(int array[], int start, int end)
 {
    int front = 0;
    int tail = end - start;
    int value = array[start];
    int length = end - start + 1;
    int loop = start + 1;

    while(loop <= end){
        if(array[loop] < value){
            gQuickSort[front] = array[loop];
            front ++;
        }else{
            gQuickSort[tail] = array[loop];
            tail --;
        }
        loop++;
    }
    gQuickSort[front] = value;
    memmove(&array[start], gQuickSort, sizeof(int) * (length));
    return start + front;
 }